﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Data;

namespace WebService
{
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        List<Category> GetCategoryList();

        [OperationContract]
        List<Product> GetProductList(int categoryID);

        [OperationContract]
        List<Product> GetPromoList();

        [OperationContract]
        Category GetCategory(int categoryID);

        [OperationContract]
        Product GetProduct(int productID);
    }

    [DataContract]
    public class Category
    {
        [DataMember]
        public int CategoryID { get; set; }
        [DataMember]
        public string Name { get; set; }
        [DataMember]
        public string Description { get; set; }

        public Category(int categoryID, string name, string description)
        {
            this.CategoryID = categoryID;
            this.Name = name;
            this.Description = description;
        }
    }

    [DataContract]
    public class Product
    {
        [DataMember]
        public int ProductID { get; set; }
        [DataMember]
        public string Name { get; set; }
        [DataMember]
        public decimal Price { get; set; }
        [DataMember]
        public int Stock { get; set; }
        [DataMember]
        public string Description { get; set; }
        [DataMember]
        public int CategoryID { get; set; }

        public Product(int productID, string name, decimal price, int stock, string description, int categoryID)
        {
            this.ProductID = productID;
            this.Name = name;
            this.Price = price;
            this.Stock = stock;
            this.Description = description;
            this.CategoryID = categoryID;
        }
    }
}
